home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Sleep Deprivation 1.0 Source / Sleep Deprivation ƒ / sd wipes ƒ / Random wipe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-12  |  2.4 KB  |  88 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Random wipe.c
  4.  
  5. Purpose:    This module handles clearing the screen in a funky
  6.             manner.  See the comments below for more details.
  7.             
  8.  
  9. Sleep Deprivation -- graphic effects on sleep
  10. Copyright (C) 1993 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define        SUB_HOR        25
  32. #define        SUB_VER        25
  33. #define        AREA        (SUB_HOR * SUB_VER)
  34. #define CorrectTime 1
  35.  
  36. void RandomWipe(GrafPtr, Pattern*);
  37.  
  38. /* Basically, we divide the window into a bunch of blocks, and copy
  39. each to the screen in random order. */
  40. void RandomWipe(GrafPtr thePtr, Pattern *thePattern)
  41. {
  42.     int        order[AREA];
  43.     int        i;
  44.     long    randtemp;
  45.     int        ordertemp;
  46.     Rect    subBox;
  47.     Rect    dest;
  48.     Boolean    everyOther;
  49.     int        width,height;
  50.     
  51.     width=thePtr->portRect.right-thePtr->portRect.left;
  52.     height=thePtr->portRect.bottom-thePtr->portRect.top;
  53.  
  54.     everyOther=FALSE;
  55.     for(i = 0; i < AREA; i++)
  56.         order[i] = i;
  57.     
  58.     for(i = (AREA - 1); i >= 0; i--) {
  59.         randtemp = ((((long)Random()) +32767) * (i + 1)) / 65535;
  60.         
  61.         ordertemp = order[randtemp];
  62.         order[randtemp] = order[i];
  63.         order[i] = ordertemp;
  64.     }
  65.     
  66.     for(i = 0; i < AREA; i++) {
  67.         StartTiming();
  68.         subBox.top = (((order[i] / SUB_VER) *
  69.                         height)
  70.                         / SUB_VER) + (thePtr->portRect).top;
  71.         subBox.left = (((order[i] % SUB_HOR) *
  72.                         width)
  73.                         / SUB_HOR) + (thePtr->portRect).left;
  74.         subBox.bottom = ((((order[i] / SUB_VER) + 1) *
  75.                         height)
  76.                         / SUB_VER) + (thePtr->portRect).top;
  77.         subBox.right = ((((order[i] % SUB_HOR) + 1) *
  78.                         width)
  79.                         / SUB_HOR) + (thePtr->portRect).left;
  80.     
  81.         FillRect(&subBox, *thePattern);
  82.             
  83.         if (everyOther)
  84.             TimeCorrection(CorrectTime);
  85.         everyOther=!everyOther;
  86.     }
  87. }
  88.